﻿Public Class DialogMenu
    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        AddHandler Datagriddetail.CellClick, AddressOf DGV_CellClick
    End Sub

    Public Overrides Function validationAdd() As Boolean
        'Return MyBase.validationAdd()
        Dim retval As Boolean = False
        If Not vnamaitemmenu.Text = String.Empty And Not vgroupmenu.SelectedValue.ToString = String.Empty Then
            retval = True
        End If
        Return retval
    End Function
    Public Overrides Function validationEdit() As Boolean
        'Return MyBase.validationEdit()
        Dim retval As Boolean = False
        If Not vnamaitemmenu.Text = String.Empty And Not viditemmenu.Text = String.Empty And Not vgroupmenu.SelectedValue.ToString = String.Empty Then
            retval = True
        End If
        Return retval
    End Function
    Public Overrides Function validationDel() As Boolean
        'Return MyBase.validationDel()
        Dim retval As Boolean = False
        If Not viditemmenu.Text = String.Empty And Not vnamaitemmenu.Text = String.Empty And Not vgroupmenu.SelectedValue.ToString = String.Empty Then
            retval = True
        End If
        Return retval
    End Function
    Public Overrides Sub ParamFind()
        MyBase.ParamFind()
        ParamCari = New Object() {"*", "vitemmenu", "namaitemmenu", ""}
    End Sub
    Sub setcombocari()
        Dim dt As New DataTable
        ComCariBy.Items.Clear()
        If Utils.executeSP("proc_showallcolumn", New Object() {"vitemmenu"}, dt) Then
            If dt IsNot Nothing Then
                If dt.Rows.Count > 0 Then
                    For Each dr As DataRow In dt.Rows
                        ComCariBy.Items.Add(dr("Field"))
                    Next
                End If
            End If
        End If
    End Sub
    Sub setcombogroup()
        Dim dt As New DataTable
        dt = New DataTable
        vgroupmenu.DataSource = Nothing
        If Utils.executeSP("proc_itemmenugroup", New Object() {"select", Convert.DBNull, Convert.DBNull}, dt) Then
            If dt IsNot Nothing Then
                If dt.Rows.Count > 0 Then
                    vgroupmenu.DataSource = dt
                    vgroupmenu.DisplayMember = "namagroupmenu"
                    vgroupmenu.ValueMember = "groupmenu"
                End If
            End If
        End If

        vimageid.Items.Clear()
        For iico As Integer = 0 To ImageList1.Images.Count - 1
            vimageid.Items.Add(iico)
        Next
    End Sub

    Private Sub DialogMenu_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ParamFind()
        searchitem()
        setentry(False)
        setcombocari()
        setcombogroup()

    End Sub


    Private Sub MbGlassButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MbGlassButton2.Click
        If Not validationEdit() Then
            MessageBox.Show("Silahkan Pilih Data Produk Pada Grid !!!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            Exit Sub
        End If
        Dim DialogMenuProduk As New DialogMenuProduk
        DialogMenuProduk.viditemmenu.Text = viditemmenu.Text
        DialogMenuProduk.vnamaitemmenu.Text = vnamaitemmenu.Text
        DialogMenuProduk.vqty.Text = vqty.Text
        DialogMenuProduk.ShowDialog()
    End Sub

    Private Sub txtKunci_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtKunci.TextChanged
        If Not ComCariBy.Text = "" Then
            ParamCari = New Object() {"*", "vitemmenu", ComCariBy.Text, txtKunci.Text}
            searchitem()
        End If
    End Sub

    Private Sub vimageid_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles vimageid.SelectedIndexChanged
        PictureBox1.Image = ImageList1.Images(vimageid.SelectedIndex)
    End Sub
End Class
